<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="com.dormitory123.millet.pojo.Order" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.dormitory123.millet.pojo.OrderItem" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>
      Shoppe商城-综合网购首选-正品低价、品质保证、配送及时、轻松购物
    </title>
    <link rel="icon" href="./static/img/common/favicon.ico" />
    <link rel="stylesheet" href="./css/base.css" />
    <link rel="stylesheet" href="./css/common.css" />
    <link rel="stylesheet" href="./css/myorder.css" />
  </head>
  <body>
  <!-- 顶部模块start -->
  <%@include file="page/common/top.jsp"%>
  <!-- 顶部模块end -->
  <!-- nav 搜索模块start -->
  <%@include file="page/common/search.jsp"%>
  <!-- nav 搜索模块end -->
    <!-- 标题 start -->
    <div class="title">
      <div class="w">
        <img src="./static/img/order/order.png" alt="" /><em>我的订单</em>
      </div>
    </div>
    <!-- 标题 end -->
    <!-- 订单 start -->
    <div class="w">
      <div class="my-order">
        <ul>
          <c:if test="${not empty sessionScope.orders&&fn:length(sessionScope.orders)!=0}">
          <c:forEach items="${sessionScope.orders}" var="order">
            <c:if test="${order.count!=0}">
              <c:set var="orderId" value="${order.orderId}" scope="session"></c:set>
              <li>
                <div class="time clearfix">
                  <div class="num">订单编号：${order.orderId}</div>
                    <%--                <fmt:formatDate value="${order.createTime}" var="time" pattern="yyyy-MM-dd"/>--%>
                  <div class="now">订单时间：${order.createTime}</div>
                </div>
                <table>
                  <thead>
                  <tr>
                    <th></th>
                    <th>商品名称</th>
                    <th>单价</th>
                    <th>数量</th>
                    <th>小计</th>
                  </tr>
                  </thead>
                    <%--                <%--%>
                    <%--                  Map<String,List<OrderItem>> orderItemMap= (Map<String, List<OrderItem>>) session.getAttribute("orderItemMap");--%>
                    <%--                  String orderId= (String) request.getAttribute("orderId");--%>
                    <%--                  System.out.println(orderId);--%>
                    <%--                  List<OrderItem> orderItems=orderItemMap.get(orderId);--%>
                    <%--                  request.setAttribute("orderItems",orderItems);--%>
                    <%--                  System.out.println(orderItems);--%>
                    <%--                %>--%>
                  <c:forEach var="item" items="${sessionScope.orderItemMap[orderId]}">
                    <tbody>
                    <tr>
                      <td><img src="${item.imgPath}"></td>
                      <td>${item.name}</td>
                      <td>${item.price}</td>
                      <td>${item.count}</td>
                      <td>${item.totalPrice}</td>
                    </tr>
                    </tbody>
                  </c:forEach>
                </table>
                <div class="total">
                  <span>共<em>${order.count}</em>件商品</span>
                  <div><em class="em1">合计：</em><em class="em2">${order.price}元</em></div>
                </div>
              </li>
            </c:if>

          </c:forEach>
          </c:if>
        </ul>
        <c:if test="${empty sessionScope.orders}">

          <div class="empty clearfix" v-else>
            <img src="./static/img/cart/cart-empty.png" alt="">
            <p class="empty1">您的订单还是空的!<br>
              <em>快去购物吧！</em>
            </p>
          </div>
        </c:if>
      </div>
    </div>
    <!-- 订单 end -->
    <!-- 页脚开始 -->
    <%@include file="page/common/bottom.jsp"%>
    <!-- 页脚结束 -->
    <script src="js/common.js"></script>
  </body>
</html>
